Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback images on site #680

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Tanujkanti4441
Copy link
Contributor

@Tanujkanti4441 Tanujkanti4441 commented Dec 21, 2024

Prerequisites checklist

What is the purpose of this pull request?

Constructing old avatar url from the new one.

What changes did you make? (Give an overview)

Did omit the private- word and jwt token from the URL of image fetched from github.

Related Issues

Fixes #679

Is there anything you'd like reviewers to focus on?

@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Dec 21, 2024
Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for ja-eslint ready!

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/ja-eslint/deploys/67793e59caade0000836446b
😎 Deploy Preview https://deploy-preview-680--ja-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for new-eslint ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/new-eslint/deploys/67793e598947fe0008115073
😎 Deploy Preview https://deploy-preview-680--new-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for es-eslint ready!

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/es-eslint/deploys/67793e592ae2fb000832af42
😎 Deploy Preview https://deploy-preview-680--es-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for zh-hans-eslint ready!

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/zh-hans-eslint/deploys/67793e59d5f1db0008d9f518
😎 Deploy Preview https://deploy-preview-680--zh-hans-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for hi-eslint ready!

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/hi-eslint/deploys/67793e59bb1c720008e02af8
😎 Deploy Preview https://deploy-preview-680--hi-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for fr-eslint ready!

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/fr-eslint/deploys/67793e59dcde5c0008d48009
😎 Deploy Preview https://deploy-preview-680--fr-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for de-eslint ready!

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/de-eslint/deploys/67793e593ad58500082e6573
😎 Deploy Preview https://deploy-preview-680--de-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 21, 2024

Deploy Preview for pt-br-eslint ready!

Name Link
🔨 Latest commit 91834de
🔍 Latest deploy log https://app.netlify.com/sites/pt-br-eslint/deploys/67793e5931d7d400083d54c9
😎 Deploy Preview https://deploy-preview-680--pt-br-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

amareshsm
amareshsm previously approved these changes Dec 21, 2024
Copy link
Member

@amareshsm amareshsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks. Leaving it open for 2nd review.

@@ -46,7 +46,7 @@ async function fetchUserProfile() {
name: profile.name,
title: "Guest Author",
website: profile.blog,
avatar_url: profile.avatar_url,
avatar_url: `${profile.avatar_url.replace("private-", "").split("?")[0]}?v=4`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
avatar_url: `${profile.avatar_url.replace("private-", "").split("?")[0]}?v=4`,
avatar_url: `${profile.avatar_url.replace("private-", "").split("?")[0]}?v=4`,

We could consider adding a fallback image in case the actual image isn't found, though I'm not sure if GitHub itself provides a fallback image.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me, should we use the fallback image which we are using for sponsors? this one
Screenshot 2024-12-21 170645

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am 👍 let's get other's opinions too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback also looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added fallback image.

@@ -96,7 +96,7 @@ async function fetchUserProfile(username) {
: profile.blog
? `https://${profile.blog}`
: profile.blog,
avatar_url: profile.avatar_url,
avatar_url: `${profile.avatar_url.replace("private-", "").split("?")[0]}?v=4`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract this into a shared place (e.g., tools/utils.js) as a function so that we don't have to repeat the same logic in multiple files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! tools/utils.js has been created.

@@ -96,7 +96,7 @@ async function fetchUserProfile(username) {
: profile.blog
? `https://${profile.blog}`
: profile.blog,
avatar_url: profile.avatar_url,
avatar_url: `${profile.avatar_url.replace("private-", "").split("?")[0]}?v=4`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some URLs have u parameter:

"name": "Workleap",
"image": "https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4",

Any ideas about what it represents?

Should we maybe remove just the jwt parameter and leave the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some URLs have u parameter:

Can it stands for unique? even though without this parameter the results are same.

Also seems links are already fixed by commit e385d5f should we still apply this fix?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also seems links are already fixed by commit e385d5f should we still apply this fix?

I also noticed that it might be a good idea to wait a couple of days. If GitHub is still testing features with a subset of users, it could potentially break again. As of now, we might not be part of the experiment, but if they do a full rollout, we could be impacted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to continue working on this PR and have it ready (or perhaps even merge it) in case the problem happens again. Unless they've decided not to continue with the change, but I couldn't find any mention of that in https://github.com/orgs/community/discussions/147297.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe remove just the jwt parameter and leave the others?

should we work on this approach? as we can see both links with and without u token gives the same result:
https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4

https://avatars.githubusercontent.com/u/53535748?v=4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to remove the JWT parameter and retain the others.

@nzakas
Copy link
Member

nzakas commented Dec 30, 2024

I think this is a bit more complicated than we need. We can easily calculate the correct URL in our fetch scripts by using the user's ID. I put this together:
#683

@Tanujkanti4441
Copy link
Contributor Author

I think this is a bit more complicated than we need. We can easily calculate the correct URL in our fetch scripts by using the user's ID. I put this together: #683

So, i think i should revert the avatar link related changes and keep only fallback related changes here?

@nzakas
Copy link
Member

nzakas commented Dec 31, 2024

I'm not sure we need the fallback changes.

Comment on lines 46 to 47
<img class="blog-post__author-photo" src="{% if params.authorImage %}{{ params.authorImage }} {% else %}../../../assets/images/people/_placeholder-avatar.svg{% endif %}" alt="{{ params.authorName }}" width="40" height="40" loading="lazy">
{% set fallback_image = '/assets/images/people/_placeholder-avatar.svg' %}
<img class="blog-post__author-photo" src="{{ params.image if params.image else fallback_image }}" alt="{{ params.authorName }}" width="40" height="40" loading="lazy" onerror="this.src = '{{fallback_image}}'">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need the fallback changes.

We can see here a fallback image is already applied but actually it's not working, can it be considered as a bug?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that can be considered a bug. I just don't think we need to add fallback images to places where we didn't have them before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the fallback image was working as intended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fallback images was only working for sponsors in All backers section as you can see in images provided in issue template of #679

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't think we need to add fallback images to places where we didn't have them before.

reverted the changes.

@Tanujkanti4441 Tanujkanti4441 changed the title fix: image sourced from github fix: fallback images on site Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working
Projects
Status: Second Review Needed
Development

Successfully merging this pull request may close these issues.

Bug: error in images fetched from github
5 participants